/*
Copyright (c) 2009-2010, Warwick Warp Limited
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.
    * Neither the name of the Warwick Warp Limited nor the
      names of its contributors may be used to endorse or promote products
      derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL WARWICK WARP LIMITED BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef WOPTIONS_ARGTRANSFORMS_H_INCLUDED
#define WOPTIONS_ARGTRANSFORMS_H_INCLUDED

#include <vector>
#include <string>

namespace woptions {

namespace basic {
	
/*!
	\brief Generic base class for transformations that can be applied to input
	arguments.
	
	\ingroup argtrans
*/
template<typename char_t>
class argument_transform
{
public:
	//! \brief Basic string type
	typedef std::basic_string<char_t> string_type;
	virtual ~argument_transform() {}
	//! \brief Apply the transfomation to the argument list.
	virtual void operator()(std::vector<string_type>& args) = 0;
};

} // namespace basic

namespace wide {

/*!
	\brief Generic base class for transformations that can be applied to input
	arguments.
	
	\ingroup argtrans
*/
typedef basic::argument_transform<wchar_t> argument_transform;
	
} // namespace wide

/*!
	\brief Generic base class for transformations that can be applied to input
	arguments.

	\ingroup argtrans
*/
typedef basic::argument_transform<char> argument_transform;

/*!
	\brief Parse command line arguments looking for 'at' specifications to 
	replace with arguments read from a file.

	Any argument begining with an 'at' (@) symbol is replaced with arguments read 
	from a file whose path is specified in the remainder of the argument. 
	Arguments in the file are whitespace separated, whitespace may be included 
	with double quotes around the argument value. The escape sequences \\ \" and 
	\n are supported.

	Two 'at' symbols (@@) at the start of an argument are treated as a single, 
	escaped, 'at' symbol.
	
	\ingroup argtrans
*/
class read_from_file : public argument_transform
{
public:
	void operator()(std::vector<string_type>& args);
};
	
}

#endif
